package com.zking.frame.TJ;

import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.Calendar;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.filechooser.FileFilter;

import com.zking.bean.Orders;
import com.zking.frame.LYK.HomepageJframe;
import com.zking.frame.TJ.JDBC.GetUserid;
import com.zking.frame.TJ.JDBC.baseDao;
import com.zking.frame.TL.Films;
import com.zking.frame.ZC.CinemaFrame;


public class mySpace extends JFrame implements MouseListener{
	private static final long serialVersionUID = 49843244L;
	
	private JPanel [] order;
	File imgFile=null;
	private int max = 0;
	private int userID=0;
	private com.zking.bean.User User;
	private String fsql=null;
	
	private  JPanel pl_top;//上部面板
	private  JLabel lb_logopic;
	private  JLabel lb_city;//选择城市
	private  JLabel lb_homepage;//首页跳转按钮
	private  JLabel lb_film;//影视页面跳转按钮
	private  JLabel lb_cinema;//电影院页面调转按钮
	private  JLabel lb_personData;//个人中心入口
	private  JLabel lb_out;//退出系统并返回登录页面
	
	//中间面板
	private JPanel pl_center;

	//中间左部导航栏面板
	private JPanel pl_centerLeft;
	private JLabel lb_mySpace;//导航栏个人空间文字
	private JLabel lb_clPersonData;//导航栏个人信息文字
	private JLabel lb_myOrder;//个人订单信息
	
	//右部个人信息面板
	private JPanel pl_centerPersonData;
	private JLabel lb_personDataTitle;//顶部标题
	private JLabel lb_dataBord;//边界线
	private JLabel lb_headPortrait;
	private JLabel lb_username;//用户名文字
	private JLabel lb_showUsername;//用户名显示框
	private JLabel lb_sex;//性别
	private JRadioButton rb_man;//复选框男
	private JRadioButton rb_woman;//复选框女
	private JLabel lb_birthday;//生日文字
	private JLabel lb_year;//文字：年
	private JComboBox<Integer> cbx_year;//年下拉框
	private JLabel lb_month;//文字：月
	private JComboBox<Integer> cbx_month;//月下拉框
	private JLabel lb_day;//文字：日
	private JComboBox<Integer> cbx_day;//日下拉框
	private JLabel lb_autograph;//文字：签名
	private JTextField tf_lb_autograph;//个人签名输入框
	private JLabel lb_secretPhone;//文字：密保手机
	private JLabel lb_secretPhones;//密保手机显示框
	private JButton bt_preservation;//保存信息按钮
	private JButton bt_changPic;//更换头像
	
	//右部个人订单面板
	private JPanel pl_centerPersonOrder;
	private JLabel lb_personOrderTitle;//顶部标题
	private JLabel lb_orderBord;//边界线
	private JScrollPane sp_order;//订单滚动面板
	private JPanel pl_smain;//订单面板
	
	public mySpace() {
		Container c = getContentPane();
		getContentPane().setLayout(null);//绝对布局，自己设定位置
		
		userID = GetUserid.getId();
		fsql="select * from user where user_id ="+userID;
		User = baseDao.findUsername(fsql);
		
	
		
		//顶部导航栏面板
		pl_top=new JPanel();
		pl_top.setBounds(0,0,1482,90);
		pl_top.setLayout(null);
		pl_top.setBackground(Color.WHITE);
		pl_top.setBorder(BorderFactory.createEtchedBorder());
		c.add(pl_top);
		
		//首页logo图片
		ImageIcon logo=new ImageIcon("imges/logo.png");
		lb_logopic=new JLabel(logo);
		lb_logopic.setBounds(60,0,logo.getIconWidth(),logo.getIconHeight());
		pl_top.add(lb_logopic);
		 
		//首页城市选择
		lb_city=new JLabel("湘潭") ;
		lb_city.setBounds(250, 10, 70, 40);
		lb_city.setFont(new Font("楷体", Font.CENTER_BASELINE, 30));
		pl_top.add(lb_city);
		
		//首页按钮
		lb_homepage=new JLabel("首页");
		lb_homepage.setBounds(360, 10, 70, 40);
		lb_homepage.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		lb_homepage.addMouseListener(this);
		pl_top.add(lb_homepage);
		
		//影视页面入口
		lb_film=new JLabel("影片");
		lb_film.setBounds(480, 10, 70, 40);
		lb_film.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		lb_film.addMouseListener(this);
		pl_top.add(lb_film);
		
		//影院入口
		lb_cinema=new JLabel("影院");
		lb_cinema.setBounds(590, 10, 70, 40);
		lb_cinema.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		lb_cinema.addMouseListener(this);
		pl_top.add(lb_cinema);
		
		//个人中心
		lb_personData=new JLabel("个人中心 ");
		lb_personData.setBounds(1230, 10, 120, 40);
		lb_personData.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		lb_personData.setForeground(Color.RED);
		lb_personData.addMouseListener(this);
		pl_top.add(lb_personData);
		 
		 //退出
		lb_out=new JLabel("|退出");
		lb_out.setBounds(1350, 10, 70, 40);
		lb_out.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		lb_out.addMouseListener(this);
		pl_top.add(lb_out);
		 
		//显示订单页面和个人信息页面的面板
		pl_center = new JPanel();
		pl_center.setBounds(0, 90,1482, 910);
		pl_center.setBackground(Color.WHITE);
		pl_center.setLayout(null);
		c.add(pl_center);
		
		//左部导航栏面板
		pl_centerLeft = new JPanel();
		pl_centerLeft.setBackground(new Color(244,243,244));
		pl_centerLeft.setBounds(150, 50, 223, 749);
		pl_centerLeft.setLayout(null);
		pl_centerLeft.setBorder(BorderFactory.createEtchedBorder());
		pl_center.add(pl_centerLeft);
		
		lb_mySpace = new JLabel("个人中心",JLabel.CENTER);
		lb_mySpace.setFont(new Font("微软雅黑", Font.PLAIN, 25));
		lb_mySpace.setBounds(0, 0, 221, 150);
		lb_mySpace.setForeground(Color.RED);
		pl_centerLeft.add(lb_mySpace);
		
		lb_clPersonData = new JLabel("基本信息",JLabel.CENTER);
		lb_clPersonData.setFont(new Font("微软雅黑", Font.PLAIN, 20));
		lb_clPersonData.setBounds(1, 150, 220, 55);
		lb_clPersonData.setOpaque(true);
		lb_clPersonData.setBackground(new Color(237,57,49));
		lb_clPersonData.addMouseListener(new MouseAdapter(){
			
			@Override
			public void mouseClicked(MouseEvent e){
				lb_clPersonData.setBackground(new Color(237,57,49));
				lb_myOrder.setBackground(new Color(244,243,244));
				pl_centerPersonData.setVisible(true);
				pl_centerPersonOrder.setVisible(false);
			}
			
			@Override
			public void mouseEntered(MouseEvent e){//鼠标进入  
				setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));  
			}
			
			@Override
			public  void mouseExited(MouseEvent e){//鼠标移除  
				setCursor(Cursor.getDefaultCursor());
			}  
			
		});
		pl_centerLeft.add(lb_clPersonData);
		
		lb_myOrder = new JLabel("我的订单",JLabel.CENTER);
		lb_myOrder.setFont(new Font("微软雅黑", Font.PLAIN, 20));
		lb_myOrder.setBounds(1, 205, 220, 55);
		lb_myOrder.setOpaque(true);
		lb_myOrder.setBackground(new Color(244,243,244));
		lb_myOrder.addMouseListener(new MouseAdapter(){
			
			@Override
			public void mouseClicked(MouseEvent e){
				lb_clPersonData.setBackground(new Color(244,243,244));
				lb_myOrder.setBackground(new Color(237,57,49));
				pl_centerPersonData.setVisible(false);
				pl_centerPersonOrder.setVisible(true);
//				for (Orders orders : myOrderList) {
//					pl_smain.add(ShowOrder(orders));
//				}
				
			}
			
			@Override
			public void mouseEntered(MouseEvent e){//鼠标进入  
				setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));  
			}
			
			@Override
			public  void mouseExited(MouseEvent e){//鼠标移除  
				setCursor(Cursor.getDefaultCursor());
			}  
			
		});
		pl_centerLeft.add(lb_myOrder);
		
		//右部个人信息面板
		pl_centerPersonData = new JPanel();
		pl_centerPersonData.setBorder(BorderFactory.createEtchedBorder());
		pl_centerPersonData.setBackground(Color.WHITE);
		pl_centerPersonData.setBounds(372, 50, 976, 749);
		pl_centerPersonData.setLayout(null);
		pl_center.add(pl_centerPersonData);
		
		lb_personDataTitle = new JLabel("基本信息",JLabel.CENTER);
		lb_personDataTitle.setFont(new Font("微软雅黑", Font.PLAIN, 20));
		lb_personDataTitle.setBounds(14, 13, 191, 70);
		lb_personDataTitle.setBackground(Color.BLUE);
		lb_personDataTitle.setForeground(Color.RED);
		pl_centerPersonData.add(lb_personDataTitle);
		
		lb_dataBord = new JLabel();
		lb_dataBord.setBounds(100, 90, 876, 3);
		lb_dataBord.setBackground(new Color(244,243,244));
		lb_dataBord.setOpaque(true);
		pl_centerPersonData.add(lb_dataBord);
		
		String headPic = User.getHeadPic();
		lb_headPortrait = new JLabel(new ImageIcon(headPic));
		lb_headPortrait.setBounds(38, 124, 296, 296);
		lb_headPortrait.setOpaque(true);
		pl_centerPersonData.add(lb_headPortrait);
		
		lb_username = new JLabel("用户名:",JLabel.CENTER);
		lb_username.setFont(new Font("宋体", Font.PLAIN, 20));
		lb_username.setBounds(380, 125, 77, 40);
		pl_centerPersonData.add(lb_username);
		
		String name = User.getUsername();
		lb_showUsername = new JLabel(name);
		lb_showUsername.setFont(new Font("宋体", Font.PLAIN, 20));
		lb_showUsername.setBounds(471, 124, 329, 40);
		pl_centerPersonData.add(lb_showUsername);
		
		lb_sex = new JLabel("性别:",JLabel.CENTER);
		lb_sex.setFont(new Font("宋体", Font.PLAIN, 20));
		lb_sex.setBounds(380, 170, 77, 40);
		pl_centerPersonData.add(lb_sex);
		
		ButtonGroup bg_select=new ButtonGroup();
		rb_man = new JRadioButton("男");
		rb_man.setBounds(471, 173, 77, 40);
		rb_man.setBackground(Color.WHITE);
		rb_man.setFont(new Font("宋体", Font.PLAIN, 20));
		rb_man.setFocusPainted(false);
		rb_man.setVisible(true);
		pl_centerPersonData.add(rb_man);
		
		rb_woman = new JRadioButton("女");
		rb_woman.setBounds(554, 172, 77, 40);
		rb_woman.setBackground(Color.WHITE);
		rb_woman.setFont(new Font("宋体", Font.PLAIN, 20));
		rb_woman.setFocusPainted(false);
		rb_woman.setVisible(true);
		pl_centerPersonData.add(rb_woman);
		
		bg_select.add(rb_man);
		bg_select.add(rb_woman);
		
		if(User.getSex()==null) {
			rb_man.setSelected(false);
			rb_woman.setSelected(false);
		}else if(User.getSex()=="男"){
			rb_man.setSelected(false);
			rb_woman.setSelected(true);
		}else {
			rb_man.setSelected(true);
			rb_woman.setSelected(false);
		}
		
		lb_birthday = new JLabel("生日:",JLabel.CENTER);
		lb_birthday.setFont(new Font("宋体", Font.PLAIN, 20));
		lb_birthday.setBounds(380, 215, 77, 40);
		
		pl_centerPersonData.add(lb_birthday);
		cbx_year = new JComboBox<Integer>();
		cbx_year.setBounds(471, 215, 79,40);
		int currYear = Calendar.getInstance().get(Calendar.YEAR);//获取今年
		for (int i = 1990; i <= 2020; i++) {
			cbx_year.addItem(i);
		}
		cbx_year.addItemListener(new ItemListener() {
			
			@Override
			public void itemStateChanged(ItemEvent e) {
			cbx_day.removeAllItems();
			max = setDay(cbx_year, cbx_month);
			for (int i = 1; i <= max; i++) {
				cbx_day.addItem(i);
			}
		}
		});
		pl_centerPersonData.add(cbx_year);
		
		lb_year = new JLabel("年");
		lb_year.setBounds(564, 215, 20, 40);
		lb_year.setFont(new Font("宋体", Font.PLAIN, 20));
		pl_centerPersonData.add(lb_year);
		
		cbx_month = new JComboBox<Integer>();
		cbx_month.setBounds(598, 215, 64,40);
		for (int i = 1; i <= 12; i++) {
			cbx_month.addItem(i);
		}
		cbx_month.addItemListener(new ItemListener() {
			
			@Override
			public void itemStateChanged(ItemEvent e) {
				cbx_day.removeAllItems();
				max = setDay(cbx_year, cbx_month);
				for (int i = 1; i <= max; i++) {
					cbx_day.addItem(i);
				}
			}
		});
		pl_centerPersonData.add(cbx_month);
		
		lb_month = new JLabel("月");
		lb_month.setBounds(676, 215, 20, 40);
		lb_month.setFont(new Font("宋体", Font.PLAIN, 20));
		pl_centerPersonData.add(lb_month);
		
		cbx_day = new JComboBox<Integer>();
		cbx_day.setBounds(710, 215, 64,40);
		pl_centerPersonData.add(cbx_day);
		
		lb_day = new JLabel("日");
		lb_day.setBounds(788, 215, 20, 40);
		lb_day.setFont(new Font("宋体", Font.PLAIN, 20));
		pl_centerPersonData.add(lb_day);
		
		if(User.getBrithday()==null) {
			cbx_year.setSelectedItem(currYear);
			cbx_month.setSelectedItem(1);
			cbx_day.setSelectedItem(1);
		}else {
			String [] birth =User.getBrithday().split("-");
			int as[]=new int[3];
			for (int i = 0; i < as.length; i++) {
				as[i]=Integer.parseInt(birth[i]);
			}
			cbx_year.setSelectedItem(as[0]);
			cbx_month.setSelectedItem(as[1]);
			cbx_day.setSelectedItem(as[2]);
		}
		
		lb_autograph = new JLabel("个人签名:",JLabel.CENTER);
		lb_autograph.setFont(new Font("宋体", Font.PLAIN, 20));
		lb_autograph.setBounds(357, 279, 100, 40);
		pl_centerPersonData.add(lb_autograph);
		
		String autograph = User.getAutograph();
		tf_lb_autograph = new JTextField();
		tf_lb_autograph.setText(autograph);
		tf_lb_autograph.setFont(new Font("宋体", Font.PLAIN, 20));
		tf_lb_autograph.setBounds(471, 281, 329, 40);
		pl_centerPersonData.add(tf_lb_autograph);
		
		lb_secretPhone = new JLabel("密保手机:",JLabel.CENTER);
		lb_secretPhone.setFont(new Font("宋体", Font.PLAIN, 20));
		lb_secretPhone.setBounds(357, 341, 100, 40);
		pl_centerPersonData.add(lb_secretPhone);
		
		String phone = User.getPhone();
		lb_secretPhones = new JLabel(phone);
		lb_secretPhones.setBounds(471, 343, 329, 40);
		lb_secretPhones.setFont(new Font("宋体", Font.PLAIN, 20));
		pl_centerPersonData.add(lb_secretPhones);
		
		//保存个人信息
		bt_preservation = new JButton(new ImageIcon(login.class.getResource("save.png")));
		bt_preservation.setBounds(471, 406, 105, 45);
		bt_preservation.setVisible(true);
		bt_preservation.setFocusable(false);
		bt_preservation.setBorder(null);
		pl_centerPersonData.add(bt_preservation);
		bt_preservation.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseClicked(MouseEvent e){
				String sex;
				String autograph=tf_lb_autograph.getText();
				String brithday =cbx_year.getSelectedItem()+"-"+cbx_month.getSelectedItem()+"-"+cbx_day.getSelectedItem();
				int user_id=User.getUser_id();
				if(rb_man.isSelected()==true){
					sex="男";
				}
				else{
					sex="女";
				}
				baseDao.updatePerson(sex, brithday, autograph, user_id);
				JOptionPane.showMessageDialog(null, "信息修改成功", "修改成功", JOptionPane.INFORMATION_MESSAGE);
				dispose();
				new mySpace();
			}
			
			@Override
			public void mouseEntered(MouseEvent e){//鼠标进入  
				setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));  
			}  
			
			@Override
			public  void mouseExited(MouseEvent e){//鼠标移除  
				setCursor(Cursor.getDefaultCursor());
			}  
		});
		
		bt_changPic = new JButton(new ImageIcon(login.class.getResource("changheadPic.png")));
		bt_changPic.setBounds(38, 465, 276, 129);
		bt_changPic.setVisible(true);
		bt_changPic.setFocusable(false);
		bt_changPic.setBorder(null);
		bt_changPic.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseClicked(MouseEvent e){
				JFileChooser fileChooser = new JFileChooser();// 新建对话框
				fileChooser.setCurrentDirectory(new File("d://"));//初始从d盘
				fileChooser.setFileFilter(new FileFilter() {  // 设置一个文件过滤器
				   @Override
				   public String getDescription() {
				      return "图片（png;jpg;jpeg）"; 
				   }
				   @Override
				   public boolean accept(File f) {
				      if (f.isDirectory()) return true;       // 目录特殊处理下
				      String fn = f.getName();
				      return fn.endsWith(".png") || fn.endsWith(".jpg")||fn.endsWith(".jpeg");// 根据后缀进行检查
				   }
				});
				int state = fileChooser.showOpenDialog(null);// 打开文件选择器界面的触发语句
				if (state == 1) {
					return;
				} else {
					imgFile = fileChooser.getSelectedFile();// f为选择到的目录
					String imgefiles = imgFile.toString().replaceAll("\\\\", "\\\\\\\\");
					baseDao.updateHeadPic(imgefiles, User.getUser_id());
					dispose();
					new mySpace();
				}
			}
		
			@Override
			public void mouseEntered(MouseEvent e){//鼠标进入  
				setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));  
			}  
			
			@Override
			public  void mouseExited(MouseEvent e){//鼠标移除  
				setCursor(Cursor.getDefaultCursor());
			}  
		});
		pl_centerPersonData.add(bt_changPic);
		
		//右部订单信息
		pl_centerPersonOrder = new JPanel();
		pl_centerPersonOrder.setBorder(BorderFactory.createEtchedBorder());
		pl_centerPersonOrder.setBackground(Color.WHITE);
		pl_centerPersonOrder.setBounds(372, 50, 976, 749);
		pl_centerPersonOrder.setLayout(null);
		pl_centerPersonOrder.setVisible(false);
		pl_center.add(pl_centerPersonOrder);
		
		lb_personOrderTitle = new JLabel("我的订单",JLabel.CENTER);
		lb_personOrderTitle.setFont(new Font("微软雅黑", Font.PLAIN, 20));
		lb_personOrderTitle.setBounds(14, 13, 191, 70);
		lb_personOrderTitle.setBackground(Color.BLUE);
		lb_personOrderTitle.setForeground(Color.RED);
		pl_centerPersonOrder.add(lb_personOrderTitle);
		
		//边界线
		lb_orderBord = new JLabel();
		lb_orderBord.setBounds(100, 90, 876, 3);
		lb_orderBord.setBackground(new Color(244,243,244));
		lb_orderBord.setOpaque(true);
		pl_centerPersonOrder.add(lb_orderBord);

		//我的订单
		sp_order = new JScrollPane();
		sp_order.setBounds(75, 150,850,550);
		pl_centerPersonOrder.add(sp_order);
		
		List <com.zking.bean.Orders> myOrderList = baseDao.findOrder(User.getUser_id());
		com.zking.bean.Orders[] myOrder = new com.zking.bean.Orders[myOrderList.size()];
		myOrderList.toArray(myOrder);
		order = new JPanel [myOrderList.size()];
		
//		JSC_movie = new JScrollPane();
//		JSC_movie.setBounds(0, 0, 803, 597);
//		JP_center_south_left_sounth.add(JSC_movie);
//		
//		//电影滚动面板中的电影面板
//		JP_movies = new JPanel();
//		JP_movies.setBackground(Color.WHITE);
//		JP_movies.setLayout(new GridLayout(2, 3, 5, 5));
//		JP_movies.setPreferredSize(new Dimension(802, 700));
//		JSC_movie.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
//		JSC_movie.setViewportView(JP_movies);
		
		pl_smain = new JPanel();
		int height = 200*myOrder.length;
//		pl_smain.setBounds(0, 0, 850, 1000);
		pl_smain.setBackground(Color.WHITE);
//		pl_smain.setLayout(new GridLayout(100, 1, 840, 200));
		pl_smain.setLayout(new GridLayout(myOrder.length,1,0,0));
		pl_smain.setPreferredSize(new Dimension(840, height));
		for (int i = 0; i < order.length; i++) {
			order[i] = ShowOrder(myOrder[i]);
//			System.out.println("==============");
//			order[i] = new JPanel();
//			pl_smain.add(order[i]);
//			pl_smain.add(order[i] = new JPanel());
			
		}
		for (int i = 0; i < order.length; i++) {
			pl_smain.add(order[i]);
		}
		sp_order.setViewportView(pl_smain);;
	
		setTitle("淘票票");//标题
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);//点击关闭按钮退出
		setSize(1500, 1000);//尺寸
		setLocationRelativeTo(null);//居中
		setVisible(true);//可见
	}
	
	
	public static void main(String[] args) {
		new mySpace();
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		Object obj=e.getSource();
		if(obj==lb_homepage) {
			dispose();
			new HomepageJframe();
		}
		if(obj==lb_film) {
			dispose();
			new Films();
		}
		if(obj==lb_out) {
			dispose();
			new login();
		}
		if(obj==lb_cinema) {
			dispose();
			new CinemaFrame();
		}
	}
	
	@Override
	public void mousePressed(MouseEvent e) {
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {

		Object obj=e.getSource();
		if(obj==lb_homepage) {
			
			lb_homepage.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
		}
		if(obj==lb_film) {
			lb_film.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
		if(obj==lb_cinema) {
			lb_cinema.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
		
		}
		if(obj==lb_personData) {
			lb_personData.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			
		}
		if(obj==lb_out) {
			lb_out.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入

		
		}
	}
	
	private int setDay(JComboBox<Integer> year, JComboBox<Integer> month) {
		int y = (int) year.getSelectedItem();
		int m =(int) month.getSelectedItem();
		Calendar c = Calendar.getInstance();
		c.set(Calendar.YEAR, y);
		c.set(Calendar.MONTH, m - 1);
		int days = c.getActualMaximum(Calendar.DAY_OF_MONTH);
		return days;
		}
	
	private JPanel ShowOrder(com.zking.bean.Orders  orders) {
		//,JPanel a
		JPanel addpl = new JPanel();
//		addpl.setBounds(x, y, width, height);
		addpl.setSize(824, 200);
		addpl.setBackground(Color.WHITE);
		addpl.setLayout(null);
//		a.add(addpl);
		 
		ImageIcon icon3=new ImageIcon(orders.getFilm_src());
		Image icon31=icon3.getImage().getScaledInstance(icon3.getIconWidth()-60, icon3.getIconHeight()-90, Image.SCALE_DEFAULT);
		icon3.setImage(icon31);
		JLabel bl_filmSrc = new JLabel(icon3);
		bl_filmSrc.setBounds(10, 10, 98, 133);
		bl_filmSrc.setOpaque(true);
		bl_filmSrc.setBackground(Color.RED);
		addpl.add(bl_filmSrc);
		
		JLabel bl_filmNmae = new JLabel(orders.getFilm_name());
		bl_filmNmae.setBounds(125, 10,220, 30);
		bl_filmNmae.setFont(new Font("宋体", Font.PLAIN, 20));
		addpl.add(bl_filmNmae);
		
//		String time = orders.getTime().replaceAll("-", " ");
		JLabel bl_time = new JLabel(orders.getTime());
		bl_time.setBounds(118, 50,220, 30);
		bl_time.setForeground(Color.GRAY);
		bl_time.setFont(new Font("幼圆", Font.PLAIN, 15));
		addpl.add(bl_time);
		
		JLabel bl_cinemaHall = new JLabel(orders.getCinema_hall());
		bl_cinemaHall.setBounds(118, 80,244, 30);
		bl_cinemaHall.setForeground(Color.GRAY);
		bl_cinemaHall.setFont(new Font("幼圆", Font.PLAIN, 15));
		addpl.add(bl_cinemaHall);
		
		JLabel bl_seat = new JLabel(orders.getSeat());
		bl_seat.setForeground(Color.GRAY);
		bl_seat.setBounds(118, 110,244, 30);
		bl_seat.setFont(new Font("幼圆", Font.PLAIN, 15));
		addpl.add(bl_seat);
		
		JLabel bl_price = new JLabel("价格："+orders.getPrice()+"元");
		bl_price.setBounds(10, 146, 249, 33);
		bl_price.setForeground(Color.GRAY);
		bl_price.setFont(new Font("幼圆", Font.PLAIN, 15));
		addpl.add(bl_price);
		
		JLabel bl_dele = new JLabel("删除订单",JLabel.CENTER);
		bl_dele.setBackground(Color.RED);
		bl_dele.setBounds(703, 94, 98, 33);
		bl_dele.setOpaque(true);
		bl_dele.setFont(new Font("幼圆", Font.PLAIN, 15));
		bl_dele.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseClicked(MouseEvent e){
				int n = JOptionPane.showConfirmDialog(null, "确认删除?", "删除确认",JOptionPane.YES_NO_OPTION);//返回的是按钮的index i=0或者1
				if(n==0) {
					baseDao.deletOrder(orders.getOrder_id());
					JOptionPane.showMessageDialog(null, "删除成功", "找回密码", JOptionPane.INFORMATION_MESSAGE);
					dispose();
					new mySpace();
				}
			}
			
			@Override
			public void mouseEntered(MouseEvent e){//鼠标进入  
				setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));  
			}  
			
			@Override
			public  void mouseExited(MouseEvent e){//鼠标移除  
				setCursor(Cursor.getDefaultCursor());
			}  
		});
		addpl.add(bl_dele);
		
		JLabel bl_south = new JLabel();
		bl_south.setBackground(new Color(240,240,240));
		bl_south.setBounds(0, 179, 834, 21);
		bl_south.setOpaque(true);
		addpl.add(bl_south);
//		System.out.println("成功！");
//		System.out.println(orders);
		
		JLabel bl_orderState = new JLabel(orders.getOrder_state(),JLabel.CENTER);
		bl_orderState.setBounds(716, 11, 98, 33);
		bl_orderState.setForeground(Color.GRAY);
		bl_orderState.setFont(new Font("幼圆", Font.PLAIN, 15));
	
		addpl.add(bl_orderState);
		
		return addpl;
	}
	
	@Override
	public void mouseExited(MouseEvent e) {
		
	}
}
